if not(myHero:GetSpellData(SUMMONER_1).name:find("SummonerFlash") or myHero:GetSpellData(SUMMONER_2).name:find("SummonerFlash") or myHero.charName=="Ezreal") then return end

function getWardSlot()
    local JumpingSlot = nil
    if GetInventorySlotItem(2045) ~= nil and myHero:CanUseSpell(GetInventorySlotItem(2045)) == READY then
        JumpingSlot = GetInventorySlotItem(2045)
    elseif GetInventorySlotItem(2049) ~= nil and myHero:CanUseSpell(GetInventorySlotItem(2049)) == READY then
        JumpingSlot = GetInventorySlotItem(2049)
    elseif myHero:CanUseSpell(ITEM_7) == READY and myHero:getItem(ITEM_7).id == 3340 or myHero:CanUseSpell(ITEM_7) == READY and myHero:getItem(ITEM_7).id == 3350 or myHero:CanUseSpell(ITEM_7) == READY and myHero:getItem(ITEM_7).id == 3361 or myHero:CanUseSpell(ITEM_7) == READY and myHero:getItem(ITEM_7).id == 3362 then
        JumpingSlot = ITEM_7
    elseif GetInventorySlotItem(2044) ~= nil and myHero:CanUseSpell(GetInventorySlotItem(2044)) == READY then
        JumpingSlot = GetInventorySlotItem(2044)
    elseif GetInventorySlotItem(2043) ~= nil and myHero:CanUseSpell(GetInventorySlotItem(2043)) == READY then
        JumpingSlot = GetInventorySlotItem(2043)
    return JumpingSlot
		end
end

function doTheFlash()
	if (myHero.charName=="Ezreal" and myHero:CanUseSpell(_E)==READY) then
		CastSpell(_E,flashFinalSpot.x,flashFinalSpot.z)
		myHero:HoldPosition()
	else
		CastSpell(flashSlot, flashFinalSpot.x, flashFinalSpot.z)
		myHero:HoldPosition()
	end
	CastSpell(RECALL) 
end


function OnDraw()
    if myHero:CanUseSpell(flashSlot) == READY then
        for i, flashSpot in pairs(Spots) do
            if GetDistance(D3DXVECTOR3(flashSpot.x, flashSpot.y, flashSpot.z)) < 2000 then
                    DrawCircle3D(flashSpot.x, flashSpot.y, flashSpot.z, 100, 5, 0xFFFF0000, 50)
                    for j, flashFinalSpot in pairs(SpotsFinal) do
                        if j == i then
                            DrawLine3D(flashSpot.x, flashSpot.y, flashSpot.z, flashFinalSpot.x, flashFinalSpot.y, flashFinalSpot.z, 3, 0xFFFF0000)
                        end
                    end
            end
        end
    end
end

function OnTick()
    if myHero:CanUseSpell(flashSlot) == READY then
        for j, flashSpot in pairs(Spots) do
            if FlashConfig.flashkey and GetDistance(D3DXVECTOR3(flashSpot.x, flashSpot.y, flashSpot.z)) < 50 then
                for k, flashFinalSpot in pairs(SpotsFinal) do
                    if k == j then
                        CastSpell(flashSlot, flashFinalSpot.x, flashFinalSpot.z)
                        if FlashConfig.recall then CastSpell(RECALL) end
                    end
                end
            elseif FlashConfig.flashkey then
                myHero:MoveTo(mousePos.x, mousePos.z)
            end
        end
    end
end

function Initialize()
    Spots = {
                { x = 3935, y = 53, z = 7214},
                { x = 8926, y = 64, z = 2402},
                { x = 5718, y = 53, z = 3502},
                { x = 7052, y = 55, z = 3223},
                { x = 7059, y = 55, z = 3081},
                { x = 5054, y = 41, z = 11998},
                { x = 6966, y = 53, z = 11282},
                { x = 6959, y = 53, z = 11416},
                { x = 8265, y = 50, z = 11103},
                { x = 9949, y = 55, z = 7249},
                { x = 11361, y = -62, z = 4257},
                { x = 5240, y = -65, z = 9233},
                { x = 5405, y = 55, z = 9926},
                { x = 8655, y = -64, z = 5195},
                { x = 8627, y = 55, z = 4545},
                { x = 2788, y = -65, z = 10204},
                
            }
    SpotsFinal = {
                    { x = 4273, y = 54, z = 7017},
                    { x = 8875, y = 55, z = 2061},
                    { x = 5375, y = 54, z = 3293},
                    { x = 7391, y = 55, z = 3297},
                    { x = 6729, y = 55, z = 2911},
                    { x = 5082, y = 40, z = 12374},
                    { x = 6619, y = 54, z = 11165},
                    { x = 7303, y = 52, z = 11525},
                    { x = 8604, y = 54, z = 11161},
                    { x = 9665, y = 54, z = 7497},
                    { x = 11435, y = -55, z = 3881},
                    { x = 4942, y = -63, z = 8970},
                    { x = 5772, y = 54, z = 10033},
                    { x = 8935, y = -64, z = 5417},
                    { x = 8267, y = 55, z = 4505},
                    { x = 2685, y = -64, z = 10567},
                    { x = 9567, y = 46, z = 6325}
                }
end

function OnLoad()
    myHero = GetMyHero()
    FlashConfig = scriptConfig("Flash Jukes", "Flash Jukes")
    FlashConfig:addParam("flashkey", "Flash Key", SCRIPT_PARAM_ONKEYDOWN, false, 84)
    FlashConfig:addParam("recall", "Recall after flash", SCRIPT_PARAM_ONOFF, true)
    if myHero:GetSpellData(SUMMONER_1).name:find("SummonerFlash") then
        flashSlot = SUMMONER_1
    elseif myHero:GetSpellData(SUMMONER_2).name:find("SummonerFlash") then
        flashSlot = SUMMONER_2
    end
    Initialize()
    PrintChat("Auto Flash when pressing T")
end
